package net.mingsoft.config;

import org.springframework.context.annotation.*;
import org.springframework.stereotype.*;
import io.swagger.models.*;
import java.util.*;
import org.aspectj.lang.annotation.*;

@Aspect
@EnableAspectJAutoProxy
@Component
public class SwaggerSuffixAspect
{
    @AfterReturning(pointcut = "execution(public io.swagger.models.Swagger springfox.documentation.swagger2.mappers.ServiceModelToSwagger2MapperImpl.mapDocumentation(..))", returning = "swagger")
    public void doBeforeBussinessCheck(final Swagger swagger) {
        final Map<String, Path> paths = (Map<String, Path>)swagger.getPaths();
        if (null != paths) {
            Map<String, Path> newPaths = new HashMap<String, Path>(paths);
            paths.clear();
            for (final String oldKey : newPaths.keySet()) {
                final String newKey = oldKey + ".do";
                paths.put(newKey, newPaths.get(oldKey));
            }
            newPaths = null;
        }
    }
}
